/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef TIMELINE_MSDP_CLIENT_IMPL_H
#define TIMELINE_MSDP_CLIENT_IMPL_H

#include <string>
#include <memory>
#include <vector>
#include <thread>
#include <map>
#include <errors.h>
#include "rdb_store.h"
#include "rdb_helper.h"
#include "rdb_open_callback.h"
#include "rdb_store_config.h"
#include "values_bucket.h"
#include "result_set.h"
#include "timeline_data_utils.h"
#include "timeline_rdb_manager.h"
#include "timeline_data_utils.h"
#include "timeline_singleton.h"
#include "timeline_interface.h"

namespace OHOS {
namespace Msdp {
class TimelineMsdpClientImpl {
public:
    using CallbackManager = std::function<int32_t(TimelineDataUtils::TimelineData&)>;

    ErrCode InitMsdpImpl();
    ErrCode RegisterImpl(CallbackManager callback);
    int32_t MsdpCallback(TimelineDataUtils::TimelineData& data);
    ErrCode EnableMsdp();
    ErrCode DisableMsdp();
    ErrCode RegisterMsdp();
    ErrCode UnregisterMsdp(void) const;
    TimelineDataUtils::TimelineData SaveObserverData(TimelineDataUtils::TimelineData& data);
    std::map<TimelineDataUtils::TimelineArea, TimelineDataUtils::TimelineValue> GetObserverData() const;
    void GetTimelineTimestamp();
    void GetLongtitude();
    void GetLatitude();
private:
    ErrCode ImplCallback(TimelineDataUtils::TimelineData& data);
    CallbackManager callbacksMgr_;
    std::unique_ptr<TimelineInterface> timelineInterface_;
    std::map<TimelineDataUtils::TimelineArea, TimelineDataUtils::TimelineValue> timelineDataMap_;
    bool notifyManagerFlag_ = false;
};
}
}
#endif // TIMELINE_MSDP_CLIENT_IMPL_H
